package org.openkoala.koala.deploy.pojo;

import java.util.ArrayList;
import java.util.List;
/**
 * 树的接口
 * @author lingen
 *
 */
public class InterfaceTree implements Itree {
	
	private String name;
	
	private List<MethodTree> children = new ArrayList<MethodTree>();
	
	private boolean check;

	public InterfaceTree(String name) {
		this.name = name;
		this.check = true;
	}


	@Override
	public String getName() {
		return name;
	}
	

	@Override
	public void setName(String name) {
		this.name  = name;
	}

	@Override
	public void setChildren(List Children) {
		this.children = Children;
	}

	@Override
	public List getChildren() {
		if(children==null)children = new ArrayList();
		return children;
	}
	
	public List<String> getSelectedChildren(){
		List<String> selecteds = new ArrayList<String>();
		if(children==null)children = new ArrayList();
		for(MethodTree method:children){
			if(method.isCheck())selecteds.add(method.getName());
		}
		return selecteds;
	}
	
	public List<MethodTree> getSelectedTree(){
		List<MethodTree> selecteds = new ArrayList<MethodTree>();
		if(children==null)children = new ArrayList();
		for(MethodTree method:children){
			if(method.isCheck())selecteds.add(method);
		}
		return selecteds;
	}


	@Override
	public boolean isCheck() {
		return check;
	}


	@Override
	public void setCheck(boolean check) {
		this.check = check;
	}

}
